#构造generator
#方法1
g = (x * x for x in range(20))
for x in g:
	print(x)
# next(g)
	
print("method 2: ")
	
#方法2

def yanghui(x):
	l = [0, 1, 0]
	yield(l[1:-1])
	for i in range(x):
		#zip(l[1:], l[:-1])
		l = [a + b for a, b in list(zip(l[1:], l[:-1]))]
		l.append(0)
		l.insert(0, 0)
		yield(l[1:-1])
	return True
	
for i in yanghui(10):
	print(i)


